package com.rfid.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.rfid.businness.AlumnoBusinness;
import com.rfid.businness.CarreraBusinness;
import com.rfid.domain.Alumno;

@Controller
public class AlumnoController {
	@Autowired
	private AlumnoBusinness alumnoBusinness;
@Autowired
	private CarreraBusinness carreraBusinness;
	
	@RequestMapping(value = "/buscar-alumno.tecsup", method = RequestMethod.POST)
	public String buscarPorNombre(ModelMap modelMap,
			@RequestParam(value = "alumno") String parametro) {
		List<Alumno> lstAlumnos = alumnoBusinness.listarPorNombre(parametro);
		if(lstAlumnos != null){
			for(Alumno al:lstAlumnos){
				al.setMyCarrera(carreraBusinness.obtenerCarrera(al.getMyCarrera().getIdCarrera()));
			}
		}
		modelMap.addAttribute("lstAlumnos", lstAlumnos);
		return "alumnos";
	}

	@RequestMapping(value = "/alumnos.tecsup", method = RequestMethod.GET)
	public String buscarAlumno() {
		return "alumnos";
	}
	

}
